﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using FPPrinter.Models.SourceFiles;
using Prism.Mvvm;

namespace FPPrinter
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        public MainWindow(SysVM sysVm)
        {
            _vm = sysVm;
            DataContext = _vm;
            
            InitializeComponent();
            DockToRightHalfOfScreen();

            _vm.Register(ver);

        }

        private void DockToRightHalfOfScreen()
        {
            // Get the primary screen's width and height
            var screenWidth = SystemParameters.PrimaryScreenWidth;
            var screenHeight = SystemParameters.PrimaryScreenHeight;

            // Set the window's width to half the screen width and its height to the screen height
            this.Width = screenWidth / 2;
            this.Height = screenHeight-40;

            // Position the window on the right half of the screen
            this.Left = screenWidth / 2;
            this.Top = 0;
        }

        private void MainWindow_OnDragOver(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.Copy;
            e.Handled = true;
        }

        private void Window_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var files = (string[])e.Data.GetData(DataFormats.FileDrop);
                
                
                _vm.LoadFiles(files);
                // Show the PDF files in the ListBox
                
            }
        }

    

        private SysVM _vm;

   

  
    }

    public class SourceFileVm: BindableBase
    {
        private ISourceFile _sourceFile;
        public SourceFileVm(ISourceFile sf )
        {
            
            _sourceFile = sf;
            Name = _sourceFile.Name;
            Url = _sourceFile.Url;
            
            Type= _sourceFile.FileType== FileType.Short? "短" : "长";
            
        }

   

        public string Name { get; set; }
        public string Url { get; set; }

        public string Type { get; set; }
    }
}